<?php
	require_once("../database/nodes.php");
	require_once("../database/hierarchies.php");
	require_once("../database/references_for_nodes.php");
	
	$node = getNode($_GET["id"]);
	$hierarchy = getHierarchy($node["hierarchy_id"]);
	
	if($node["node_id"] != NULL){
		$father = getNode($node["node_id"]);
		$father_hierarchy = getHierarchy($father["hierarchy_id"]);
	}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<title><?php echo utf8_decode($hierarchy["name"]." ".$node["name"]) ?></title>
	</head>
	<body>
		<div>
			<a href="root.php">Up to Root nodes</a><br>
		<?php
			if($node["node_id"] != NULL){
				echo "<a href=\"show.php?id=".$father["id"]."\">Up to ".$father_hierarchy["name"]." ".$father["name"]."</a>";
			}
		?>
		</div>
		<h1><?php echo utf8_decode($hierarchy["name"]." ".$node["name"]) ?></h1>
		<ul>
			<li><a href="new.php?node_id=<?php echo $node["id"] ?>">Create a new node inside this</a></li>
			<li><a href="edit.php?id=<?php echo $node["id"] ?>">Edit this node</a></li>
			<li><a href="confirm_deletion.php?id=<?php echo $node["id"] ?>">Delete this node and <em>everything</em> under it</a></li>
		</ul>
		<h2>Short description</h2>
		<p><?php echo utf8_decode($node["short_desc"]) ?></p>
		<h2>Long description</h2>
		<p><?php echo utf8_decode($node["long_desc"]) ?></p>
		<h2>References</h2>
		<a href="new_reference.php?node_id=<?php echo $_GET["id"] ?>">Create a new reference</a>
		<?php
			printReferencesAsList($_GET["id"]);
		?>
		<div>
			<form name="down_to_son" id="down_to_son" action="down_to.php" method="post">
				<label for="id">Down to </label>
				<select name="id" id="id">
					<?php
						printChildrenNodesAsOptions($_GET["id"]);
					?>					
				</select>
				<input type="submit" value="Go">
			</form>
		</div>
	</body>
</html>
